#include "VUMeter.h"
#include "Captuer.h"

VUMeter::VUMeter(wxPanel *parent, int id)
      : wxPanel(parent, id, wxDefaultPosition, wxSize(-1, 30), wxSUNKEN_BORDER) {
 
  m_parent = parent;

  Connect(wxEVT_PAINT, wxPaintEventHandler(VUMeter::OnPaint));
  Connect(wxEVT_SIZE, wxSizeEventHandler(VUMeter::OnSize));

}

void VUMeter::OnPaint(wxPaintEvent& event) {
  wxPaintDC dc(this);
  wxSize size = GetSize();
  int width = size.GetWidth();

  int cur_width = 500;

  int step = (int) round(width / 10.0);


  int till = (int) ((width / 50.0) * cur_width);


  dc.SetPen(wxPen(wxColour(255, 0, 0)));
  dc.SetBrush(wxBrush(wxColour(255, 0, 0)));
  dc.DrawRectangle(0, 0, till*volume, 30);

  

 
}

void VUMeter::OnSize(wxSizeEvent& event) {
  Refresh();
}


void VUMeter::setVolume(float _volume) {
	volume = _volume;
	Refresh();
}
